#!/bin/sh

skip_next=0
args=""

for arg in "$@"; do
  if [ $skip_next -eq 0 ]; then
    if [ "$arg" = "-G" ] ; then
        args="$args -shared";
    elif [ "$arg" = "-dy" ] ; then
        ; # skipping
    elif [ "$arg" = "-M" ]; then
         skip_next=1; # skipping this one and the next one
    else 
         args="$args $arg"
    fi
  else 
    skip_next=0;
  fi
done

$args="$args"

#echo Running /usr/gnu/bin/ld $args >> /tmp/ld.log
exec /usr/bin/env LD_PRELOAD=/usr/lib/extendedFILE.so.1 /usr/gnu/bin/ld $args
